package sbc.group1.lab1.common;

import java.awt.Color;

public class CarBody extends Part implements Coatable {

	private Color color = null;
	private int coaterId;
	
	@Deprecated
	public CarBody(Producer producer) {
		super(producer);
	}
	
    public CarBody(Producer producer, boolean isDefect) {
        super(producer, isDefect);
    }

    public void coat(Color color, Coater coater) {
        if (color!=null) {
            this.color=color;
            this.coaterId=coater.getId();
        }else {
            throw new NullPointerException("Color must not be null.");
        }
    }
    
    public Color getColor() {
        return color;
    }

    @Override
    public int coatedBy() {
        return coaterId;
    }

    @Override
    public boolean isCoated() {
        return color!=null;
    }
    
    @Override
    public String toString() {
        String str=super.toString();
        return str.substring(0,str.length()-1)+", color="+ 
        (color == null ? "null" : color.toString())+"]";
    }
}
